package uz.edo.app.admin.organizationPages;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import uz.edo.app.admin.AdminPage;
import uz.edo.db.bean.Organisation;
import uz.edo.db.manager.OrganisationManager;

/**
 * Created by IntelliJ IDEA.
 * User: said
 * Date: 1/23/12
 * Time: 3:02 AM
 * To change this template use File | Settings | File Templates.
 */
public class OrganisationAdd extends AdminPage{

    private OrganisationManager manager = OrganisationManager.getInstance();
    private Organisation organisation;

    public OrganisationAdd() {
        organisation = new Organisation();
        CompoundPropertyModel model = new CompoundPropertyModel(organisation);
        Form form = new Form("form",model){
            @Override
            protected void onSubmit() {
                try {
                    manager.saveOrUpdate(organisation);
                    setResponsePage(OrganisationListView.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        add(form);
        form.add(new TextField("nameUz"));
        form.add(new TextField("nameRu"));
    }
}
